package org.jeecg.modules.online.cgform.enhance.impl;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.online.cgform.enhance.CgformEnhanceJavaInter;
import org.jeecg.modules.online.config.exception.BusinessException;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * Excel导入增强，针对导入数据进行check或者数据转换
 */
@Slf4j
@Component("cgformEnhanceImportDemo")
public class CgformEnhanceImportDemo implements CgformEnhanceJavaInter{

	@Override
	public int execute(String tableName, JSONObject json) throws BusinessException {
		log.info("--------我是自定义java增强测试bean 导入示例-----------");
		log.info("--------当前tableName=>"+tableName);
		log.info("--------当前JSON数据=>"+json.toJSONString());

		if(json.get("ee")==null){
			return 1;
		}

		if(json.getString("ee").equals("hello")){
			json.put("id","testid123");
			json.put("ee","java 增强导入测试修改");
			return 2;
		}

		if(json.getString("ee").equals("ok")){
			// 如果丢弃数据，直接返回0
			return 0;
		}
		//业务代码
		return 1;
	}


	@Override
	public int execute(String tableName, Map<String, Object> map) throws BusinessException {
		return 1;
	}

}
